﻿using System;
using System.ServiceModel;

namespace Sushi.Core
{
   /// <summary>
   /// Provides a proxy to a hosted instance of the <see cref="ISushiService"/> interface.
   /// </summary>
   public class SushiServiceProxy : ClientBase<ISushiService>, ISushiService, IDisposable
   {
      /// <summary>
      /// Executes a proxied request to the <see cref="ISushiService"/> method.
      /// </summary>
      /// <param name="request">The report request.</param>
      /// <returns>The deserialized report response.</returns>
      public GetReportResponse GetReport(GetReportRequest request)
      {
         return Channel.GetReport(request);
      }

		//added to the system generated class to fix a bug that hide exceptions
		void IDisposable.Dispose()
		{
			if (this.State == CommunicationState.Faulted)
				this.Abort();

			this.Close();
		}

   }
}